
//
//  KAgreementViewController.m
//  Keping
//
//  Created by 柯平 on 2017/6/30.
//  Copyright © 2017年 柯平. All rights reserved.
//

#import "KAgreementViewController.h"
#import <WebKit/WebKit.h>
#import "KUserProtocolRequest.h"
#import "KProtocolData.h"
#import "ZMZWebContentView.h"

@interface KAgreementViewController ()<WKUIDelegate>
@property(nonatomic,strong)ZMZWebContentView* baseWebView;
@property (nonatomic, strong) UIProgressView *progressView;

@end

@implementation KAgreementViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    ZMZWebContentView *webView = [[ZMZWebContentView alloc] initWithFrame:self.view.bounds];
    webView.backgroundColor = kWhiteColor;
    WEAKSELF
    [webView setShouldStartLoadBlock:^BOOL(WKWebView *webView, NSURLRequest *request) {
        [weakSelf showLoading];
        return YES;
    }];
    [webView setFinshLoadBlock:^(WKWebView *webView) {
        [weakSelf hideHUD];
    }];
    webView.propressBlock = ^(CGFloat propress) {
        weakSelf.progressView.progress = propress;
        if (propress == 1.0) {
            [UIView animateWithDuration:0.25f delay:0.3f options:UIViewAnimationOptionCurveEaseOut animations:^{
                weakSelf.progressView.transform = CGAffineTransformMakeScale(1.0f, 1.4f);
            } completion:^(BOOL finished) {
                weakSelf.progressView.hidden = YES;
            }];
        } else {
            weakSelf.progressView.hidden = NO;
        }
    };
    webView.titleBlock = ^(NSString *title) {
        weakSelf.title = title;
    };
    [self.view addSubview:webView];
    self.baseWebView = webView;
    [self.baseWebView loadRequestWithURLString:@"https://www.linktime.com.my/terms-conditions/"];
    
    self.progressView = [[UIProgressView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 2)];
    self.progressView.backgroundColor = [UIColor blueColor];
    //设置进度条的高度，下面这句代码表示进度条的宽度变为原来的1倍，高度变为原来的1.5倍.
    self.progressView.transform = CGAffineTransformMakeScale(1.0f, 1.5f);
    [self.view addSubview:self.progressView];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
